export function getTreeData(data) {
    const map = {};
    const treeData = []
    data.forEach((item) => {
        map[item.cid] = item
    })
    data.forEach((item) => {
        let parent = map[item.pid]
        if (parent) {
            if (!(parent.children instanceof Array)) {
                parent.children = new Array();
            }
            parent.children.push(item);
            // (parent.children || (parent.children = new Array())).push(item);
        } else treeData.push(item)
    })
    return treeData
}